import service from './request'
//request() 返回的是一个 Promise
//登录
export function login(data) {
    return service({
        url: 'login',
        method: "GET",
        params: data
    })
}
//左侧菜单路由
export function menus(data) {
    return service({
        url: 'menus',
        method: "GET",
        data: data
    })
}
//用户数据列表
export function GetUsersList(data) {
    return service({
        url: 'users',
        method: "GET",
        params: data
    })
}
//添加用户
export function AddUsers(data) {
    return service({
        url: 'users',
        method: "POST",
        data: data
    })
}
//编辑用户提交
export function editUser(id, data) {
    return service({
        url: `users/${id}`,
        method: "PUT",
        data: data
    })
}
// 修改用户状态
export function changeStatus(data) {
    return service({
        url: `users/${data.uid}/state/${data.type}`,
        method: "PUT",
        params: ''
    })
}
// 删除单个用户
export function DeleteUser(data) {
    return service({
        url: `users/${data.id}`,
        method: "DELETE",
        params: ''
    })
}

//角色列表 查询
export function getRoles(id, data) {
    const rolesUrl = id == '' || 'undefined' ? 'roles' : `roles/${id}`
    return service({
        url: rolesUrl,
        method: "GET",
        params: data
    })
}
// 分配用户角色
export function allotRoles(id, data) {
    return service({
        url: `users/${id}/role`,
        method: "PUT",
        data: data
    })
}
// 删除用户角色
export function DeleteRoles(id) {
    return service({
        url: `roles/${id}`,
        method: "DELETE",
        params: ''
    })
}
// 查询用户角色
export function SearchRoles(data) {
    return service({
        url: `roles/${data.id}`,
        method: "DELETE",
        params: ''
    })
}
//添加用户角色
export function AddRoles(data) {
    return service({
        url: 'roles',
        method: "POST",
        data: data
    })
}
//编辑用户角色提交
export function editRoles(id, data) {
    return service({
        url: `roles/${id}`,
        method: "PUT",
        data: data
    })
}
// 所有权限列表
export function allRights(type, data) {
    return service({
        url: `rights/${type}`,
        method: "GET",
        data: data
    })
}
// 角色授权
export function userRights(id, data) {
    return service({
        url: `roles/${id}/rights`,
        method: "POST",
        data: data
    })
}
//商品数据列表
export function GetGoodsList(data) {
    return service({
        url: 'goods',
        method: "GET",
        params: data
    })
}
//商品数据查询
export function SearchGoodsList(id) {
    return service({
        url: 'goods/' + id,
        method: "GET",
        params: ''
    })
}
// 删除商品
export function DeleteGoods(data) {
    return service({
        url: `goods/${data.id}`,
        method: "DELETE",
        params: ''
    })
}